package base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Administrator on 2016/10/13.
 * 作用父类，公共类
 *
 *
 */
public abstract class BaseFragment extends Fragment {


    //上下文
    protected Context mcontext;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mcontext=getActivity();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return initview();
    }
     //强制子类重写，实现子类特有的ui
    protected abstract View initview();

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        initData();
    }
    //当子类需要初始化数据，或者联网请求，绑定数据或者展示数据时；可以重写该方法
    protected void initData() {
    }


}
